﻿using System;
using System.Data;
using System.Collections;
using System.Text.RegularExpressions;
using System.Text;
using System.Web.Caching;

using LTJ.Common;
using LTJ.Data;
using LTJ.Config;
using LTJ.Entity;
using LTJ.Common.Generic;
using LTJ.Cache;


namespace LTJ.FrameWork
{
    /// <summary>
    /// 用户组操作类
    /// </summary>
    public class UserGroup
    {

        /// <summary>
        /// 创建新用户组.
        /// </summary>
        /// <param name="__userinfo">用户信息</param>
        /// <returns>返回用户ID, 如果已存在该用户名则返回-1</returns>
        public static int CreateUserGroup(UserGroupInfo usergroupInfo)
        {
            if (GetUserGroupId(usergroupInfo.name) > 0)
                return -1;
            return LTJ.Data.DataProvider.UserGroup.CreateUserGroup(usergroupInfo);
        }
        /// <summary>
        /// 根据用户组名返回用户组id
        /// </summary>
        /// <param name="username">用户名</param>
        /// <returns>用户id</returns>
        public static int GetUserGroupId(string usergroupname)
        {
            UserGroupInfo usergroupInfo = LTJ.Data.DataProvider.UserGroup.GetUserGroupInfoByName(usergroupname);
            return (usergroupInfo != null) ? usergroupInfo.id : 0;
        }

        public static DataTable GetUserGroupList(string strWhere)
        {
            return LTJ.Data.DataProvider.UserGroup.GetUserGroupList(strWhere);
        }
        /// <summary>
        /// 删除用户组信息
        /// </summary>
        /// <param name="ids">用户组id组合</param>
        /// <returns></returns>
        public static int DelUserGroup(string ids)
        {
            return LTJ.Data.DataProvider.UserGroup.DelUserGroup(ids);
        }
        /// <summary>
        /// 根据用户组id获取用户组实体
        /// </summary>
        /// <param name="id">用户组id</param>
        /// <returns></returns>
        public static LTJ.Entity.UserGroupInfo GetUserGroupInfo(int id)
        {
            return LTJ.Data.DataProvider.UserGroup.GetUserGroupInfo(id);
        }
        /// <summary>
        /// 修改用户组
        /// </summary>
        /// <param name="ugInfo"></param>
        public static bool UpdateUserGroup(LTJ.Entity.UserGroupInfo ugInfo)
        {
            return LTJ.Data.DataProvider.UserGroup.UpdateUserGroup(ugInfo);
        }
    }
}
